<template>
<div class="detail-wrap">
<div class="container">
  <product-head/>

  <div class="content">
    <div class="swiper-wrap">
      <swiper :options="swiperOptions">
        <swiper-slide><img src="/imgs/detail/phone-1.jpg" alt=""></swiper-slide>
        <swiper-slide><img src="/imgs/detail/phone-2.jpg" alt=""></swiper-slide>
        <swiper-slide><img src="/imgs/detail/phone-3.jpg" alt=""></swiper-slide>
        <swiper-slide><img src="/imgs/detail/phone-4.jpg" alt=""></swiper-slide>
        <div class="swiper-pagination"  slot="pagination"></div>
      </swiper>
    </div>
    <div class="pro-info">
      <h3>{{detailList.name}}</h3>
      <p>相机全新升级/960帧慢动作/手持超级夜景/全球首款双频GPS／骁龙845处理器/红外人脸解锁/AI变焦双摄/三星AMOLED屏</p>
      <div class="price">
        <p class="text">小米自营</p>
        <p class="text">{{detailList.price}}元 <span>1999元</span></p>
      </div>

      <div class="supply">
        <i></i>
        <div class="address">
          北京 北京市 朝阳区 安定门街道
        </div>
        <div class="the-spot">
          有现货
        </div>
      </div>

      <div class="version">
        <h4>选择版本</h4>
        <div>
          <div class="phone" :class="{checked:version===1}" @click="version=1">6GB+64GB全网通</div>
          <div class="phone" :class="{checked:version===2}" @click="version=2">4GB+64GB全网通</div>
        </div>
      </div>

      <div class="color">
        <h4>选择颜色</h4>
        <div class="change-color">
          <span></span>
          深空灰
        </div>
      </div>

      <div class="item-total">
        <div class="phone-info clearfix">
          <div class="fl">{{this.version===1?'6GB+64GB 移动4G 深灰色':'4GB+64GB全网通'}}</div>
          <div class="fr">{{detailList.price}}元</div>
        </div>
        <div class="phone-total">总计：{{detailList.price}}元</div>
      </div>

      <div class="btn-group">
        <a href="javascript:;" class="btn btn-huge fl" >加入购物车</a>
      </div>

    </div>
  </div>
</div>
  <div class="pro1-info">
    <div class="container">
      <h2>价格说明</h2>
      <div class="desc">
        <img src="/imgs/detail/item-price.jpeg" alt="">
      </div>
    </div>
  </div>
  <div class="container">
    <service-bar/>
  </div>
</div>
</template>

<script>
import ProductHead from "../components/ProducrHead/ProductHead";
import ServiceBar from '../components/ServiceBar/servicebar';
import {SwiperSlide,Swiper} from "vue-awesome-swiper";
export default {
name: "detail",
  data(){
  return{
    swiperOptions:{
      pagination: {
        el: '.swiper-pagination',
      },
      autoplay:true
    },
    detailList:{},
    version:1
  }
  },
  components:{
    ProductHead,
    SwiperSlide,
    Swiper,
    ServiceBar
  },
  created() {
    this.getDetail()
  },
  methods:{
    getDetail(){
      this.axios.get(`/products/${this.$route.params.id}`).then(res=>{
        this.detailList = res;
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../assets/scss/base.scss";
@import "../assets/scss/mixin.scss";
@import "../assets/scss/config.scss";
@import "../assets/scss/button.scss";
.detail-wrap{
  .content{
    width: 100%;
    height: 870px;
    display: flex;
    justify-content: space-between;
    .swiper-wrap{
      width: 563px;
      height: 617px;
      margin-top: 5px;
      img{
        width: 100%;
        height: 100%;
      }
    }
    .pro-info{
      h3{
        font-size: 28px;
        padding-top: 30px;
        padding-bottom: 16px;
        line-height: 26px;
      }
      p{
        font-size: 16px;
        height: 36px;
      }
      .price{
        font-size: 20px;
        margin-top: 26px;
        color: #FF6600;
        .text{
          height: 15px;
          line-height: 15px;
          span{
            font-size: 16px;
            color: #999999;
            text-decoration: line-through;
          }
          &:first-child{
            margin-bottom: 14px;
          }
          &:last-child{
            padding-bottom: 25px;
            margin-bottom: 28px;
            border-bottom: 1px solid #e5e5e5;
          }
        }
      }
      .supply{
        height: 108px;
        background-color: #fafafa;
        border:1px solid #e5e5e5;
        box-sizing: border-box;
        padding-top: 31px;
        padding-left: 64px;
        font-size: 14px;
        line-height: 14px;
        .address{
          color: #666666;
        }
        .the-spot{
          margin-top: 15px;
          color: #FF6600;
        }
      }
      .version{
        margin-top: 30px;
        h4{
          font-size: 18px;
          margin-bottom: 20px;
        }
        div{
          .phone{
            display: inline-block;
            width: 275px;
            height: 50px;
            line-height: 50px;
            text-align: center;
            border:1px solid #e5e5e5;
            font-size: 16px;
            cursor: pointer;
            &:last-child{
              margin-left: 9px;
            }
          }
          .checked{
            color: #FF6600;
            border: 1px solid #FF6600;
          }
        }
      }
      .color{
        margin-top: 30px;
        h4{
          font-size: 18px;
          margin-bottom: 20px;
        }
        .change-color{
          width: 275px;
          height: 50px;
          font-size: 16px;
          line-height: 50px;
          text-align: center;
          border: 1px solid #e5e5e5;
          span{
            display: inline-block;
            width: 14px;
            height: 14px;
            background-color: #666666;
          }
        }
      }
      .item-total{
        height: 108px;
        background: #FAFAFA;
        padding: 24px 33px 29px 30px;
        font-size: 14px;
        margin-top:50px;
        margin-bottom:30px;
        box-sizing: border-box;
        .phone-info{
          .fl{
            float: left;
            width: 250px;
          }
          .fr{
            float: right;
            width: 250px;
            text-align: right;
          }
        }
        .phone-total{
          font-size: 24px;
          color: #FF6600;
          margin-top: 18px;
        }
      }
    }
    .checked{
      color: #FF6600;
      border: 1px solid #FF6600;
    }
  }
  .pro1-info{
    background-color: #f3f3f3;
    height: 340px;
    h2{
      font-size: 24px;
      color: #333333;
      padding-top: 38px;
      margin-bottom: 30px;
    }
    .desc{
      img{
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }
  }
}
</style>
